﻿using D.Medicalcare.ErrorCode;
using D.Medicalcare.Write.API.Application.Commands.PatientCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Write.API.Controllers
{
    /// <summary>
    /// 就诊人管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PatientController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 中介者
        /// </summary>
        /// <param name="mediator">中介者</param>
        public PatientController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加就诊人
        /// </summary>
        /// <param name="request">参数</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public Task<APIResult<object>> CreatePatient(CreatePatientCommand request)
        {
           return mediator.Send(request);

        }
        /// <summary>
        /// 默认值批量修改
        /// </summary>
        /// <param name="request">参数</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdatePatient([FromQuery]UpdatePatientCommand request)
        {
            return await mediator.Send(request);

        }
        /// <summary>
        /// 默认值批量修改
        /// </summary>
        /// <param name="request">参数</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public async Task<APIResult<object>> UpdateIsdefault([FromQuery]UpdateIsdefaultCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
